﻿using System;

namespace Microsoft.Popfly.GameCreator.GameEngine.Behaviors
{
    public class ContinuedBehavior : IBehavior
    {

        private Game m_game;
        private BehaviorOwner m_owner;
        private IBehavior m_behavior;

        public ContinuedBehavior(Game game, BehaviorOwner owner, IBehavior behavior)
        {
            m_game = game;
            m_owner = owner;
            m_behavior = behavior;
        }

        #region Behavior Members

        public void Invoke(BehaviorOwner sender, Microsoft.Popfly.GameCreator.GameEngine.Events.PGCEventArgs args)
        {
            // keep doing the behavior every frame
            m_owner.AddBehavior(
                new Events.StandardListener(
                    m_game,
                    m_owner,
                    null,
                    m_behavior,
                    null, 
                    null,
                    new Events.EveryFrameChecker(m_game)
                    )
                );
        }

        #endregion
    }
}
